programming4us
           
 
 
Programming

iPad SDK : Implementing an About Panel in a Modal Way (part 1) - Creating the Modal Web View Controller

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
12/2/2010 2:40:43 PM

We'll present a UIWebView with information about Dudel and links at the bottom to get additional information. This web view will be presented modally, just like the file-renaming view.

As you may know, the Dudel application created during the writing of this book is actually available on the App Store as a free download. This is partly because while creating it, we found it was fun to use and worthy of making available to others. But we also figured that it could be a good way to promote the book itself!

The shipping version of Dudel includes an info screen that describes this book, tells the users that they can buy this book if they want to see how the app was made, and provides links to the Apress and Amazon web sites. In order to keep our promise to include full details on how to make this app, we're going to make the same info screen that could lead you to buying this book—if you didn't already have a copy, which you do. How self-referential is this?

1. Creating the Modal Web View Controller

Start by creating a new UIViewController class called ModalWebViewController, again with an .xib file and without being a subclass of UITableViewController. Give it the following interface declaration in ModalWebViewController.h:

//  ModalWebViewController.h
#import <UIKit/UIKit.h>
@protocol ModalWebViewControllerDelegate;
@interface ModalWebViewController : UIViewController {
id <ModalWebViewControllerDelegate> delegate;
UIWebView *webView;
}
@property (nonatomic, assign) id <ModalWebViewControllerDelegate> delegate;
@property (nonatomic, retain) IBOutlet UIWebView *webView;
- (IBAction)done;
- (IBAction)apressSite;
- (IBAction)amazonSite;

@end
@protocol ModalWebViewControllerDelegate
- (void)modalWebViewControllerDidFinish:(ModalWebViewController *)controller;
@end


Now open ModalWebViewController.xib in Interface Builder, and once again use the attribute inspector to disable the view's status bar. Then use the size inspector to set the view's size to 540 by 620. Use the Library to find a UIToolbar and put it at the bottom of the view, and then add a UIWebView to fill up the rest of the view. Now put five UIBarButtonItems into the toolbar. Use the attribute inspector to set the fourth button's identifier to Flexible Space, and the fifth item's identifier to Done. Then set the titles on the remaining three to More Info, Buy the eBook, and Buy the Print Book, respectively, as shown in Figure 1.

Figure 1. The toolbar for our ModalWebViewController

Control-drag to connect each of the four clickable buttons to the appropriate action methods in File's Owner: apressSite, apressSite, amazonSite, and done. (Yes, we're reusing the same method for both the More Info and Buy the eBook actions.)

Now control-drag from the File's Owner icon to the UIWebView, and connect the webView outlet. The GUI is complete. Save your work and switch back to Xcode to finish up this class. Here's the code for ModalWebViewController.m:

//  ModalWebViewController.m
#import "ModalWebViewController.h"
@implementation ModalWebViewController
@synthesize delegate;
@synthesize webView;
- (void)viewDidLoad {
// Load the bookInfo.html file into the UIWebView.
NSString *path = [[NSBundle mainBundle] pathForResource:@"bookInfo" ofType:@"html"];
NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:request];
[super viewDidLoad];
}
- (IBAction)done {
// The Done button was tapped, so close Modal Web View.
[self.delegate modalWebViewControllerDidFinish:self];
}
- (IBAction)apressSite {
// Go to the Apress.com book web page in Mobile Safari.
NSURL *url = [NSURL URLWithString:@"http://www.apress.com/book/view/9781430230212"];
[[UIApplication sharedApplication] openURL:url];
}
- (IBAction)amazonSite {
// Go to the Amazon.com book web page in Mobile Safari.
NSURL *url = [NSURL URLWithString:@"http://www.amazon.com/dp/1430230215/"];
[[UIApplication sharedApplication] openURL:url];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation {
// Overridden to allow any orientation.
return YES;
}
- (void)dealloc {
[webView release];
[super dealloc];
}
@end


Other -----------------
- Parallel Programming with Microsoft .Net : Dynamic Task Parallelism - Variations
- Keyword Research Tools (part 7) - comScore Marketer
- Keyword Research Tools (part 6)
- Keyword Research Tools (part 5)
- Keyword Research Tools (part 4)
- Keyword Research Tools (part 3)
- Keyword Research Tools (part 2)
- Keyword Research Tools (part 1) - Keyword Research Data from the Engines
- The Art of SEO : Traditional Approaches: Domain Expertise, Site Content Analysis
- The Art of SEO : The Theory Behind Keyword Research
- jQuery 1.3 : Headline rotator (part 7)
- jQuery 1.3 : Headline rotator (part 6)
- jQuery 1.3 : Headline rotator (part 5) - Pause on hover
- jQuery 1.3 : Headline rotator (part 4) - The headline rotate function
- jQuery 1.3 : Headline rotator (part 3) - Setting up the rotator
- jQuery 1.3 : Headline rotator (part 2) - Retrieving the feed
- jQuery 1.3 : Headline rotator (part1) - Setting up the page
- Benchmarking Current Rankingstages of SEO
- First Stages of SEO : Benchmarking Current Rankings
- First Stages of SEO : Benchmarking Current Indexing Status
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us